import 'dart:developer';
import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:huxiaodui/config.dart';
import 'package:huxiaodui/main.dart';
import 'package:huxiaodui/utils/tools/notification_tool.dart';
import 'package:dio/dio.dart';
import 'package:dio/io.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:install_plugin/install_plugin.dart';
import 'package:path_provider/path_provider.dart';

class IOSUpdate {
  static show({
    required String version,
    required String url,
    Widget? content,
  }) async {
    if (!Platform.isIOS) {
      return;
    }
    showDialog(
      context: navigatorKey.currentState!.context,
      builder: (context) => AlertDialog(
        title: Text("发现新版本 $version"),
        content: content,
        actions: [
          TextButton(
            child: const Text('前往更新'),
            onPressed: () async {
              Navigator.pop(context, true);
              await InstallPlugin.install(url);
            },
          ),
        ],
      ),
    );
  }
}
